Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions Rebuild #1132

Merged
merged 10 commits into from
Oct 10, 2024
Merged

Github Actions Rebuild #1132

merged 10 commits into from
Oct 10, 2024

Conversation

bmos
Copy link
Contributor

@bmos bmos commented Sep 7, 2024

This is a total rebuild of how our action yml files are structured, with the python tests now occuring in a single multi-job action. This works much better in the GitHub web UI. This also allows the easy stuff (linting, formatting, etc) to finish much faster than the pytest runs. It also adds additional security checks and automatic dependency updates.

What it does

  • Run pytest on every version of macOS (since only pytest and pip install run on macOS it should use too much time -- linting, formatting, coverage, etc are only run once).
  • Remove file name filters on action triggers so actions run on ever pushed commit / active pull request rather than trying to limit runs to when certain files are updated (to ensure nothing is missed and make it more obvious if actions fail to run for some reason)
  • Move test.yml and pip-install.yml to shared python-checks.yml
  • Add automatic weekly dependency pull requests with dependabot covering github actions, docker, and pip
  • Add code coverage checking with coverage failing when the project has <75% coverage (for now) - important for Test Coverage Assessment #1114
  • Add code security checks with bandit (filtered to medium or higher risk and medium or higher confidence)
  • Update security scorecard to pin hash of github/codeql-action/upload-sarif
  • Update security scorecard to first harden the runner
  • Update security scorecard to scan major-release branch along with main
  • Update ruff, pytest, and similar

What's needed to merge

  • Resolve the 4 issues found by bandit
    • defusedxml
    • md5

.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Dismissed Show dismissed Hide dismissed
.github/workflows/python-checks.yml Dismissed Show dismissed Hide dismissed
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@anzelpwj
Copy link
Contributor

anzelpwj commented Sep 7, 2024

Just FYI to anyone doing a more proper review - the reason a large number of files are changed is because isort sorted the imports.

Edit: Now a lot of fixes recommended from bandit (e.g. using defusedxml, specifying md5 as not being used for security).

.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
.github/workflows/python-checks.yml Fixed Show fixed Hide fixed
@bmos bmos force-pushed the mod-action branch 4 times, most recently from bbc143d to 8e1cda5 Compare September 7, 2024 17:27
@anzelpwj anzelpwj mentioned this pull request Sep 7, 2024
Copy link
Collaborator

@shaunagm shaunagm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@bmos bmos force-pushed the mod-action branch 4 times, most recently from fff0efc to af59262 Compare September 17, 2024 21:10
@bmos
Copy link
Contributor Author

bmos commented Sep 17, 2024

So the issue is that the gmail address validation is acting differently across different platforms and python versions.
Specifically, the test of validation behavior for email addresses of ",com" instead of ".com" is passing (mostly on older versions). I'm guessing there is a package we don't have pinned to a specific version and it's exhibiting different behavior based on what version is installed.

@shaunagm
Copy link
Collaborator

shaunagm commented Sep 18, 2024

I did a little investigating. The test failure is on the gmail connector, which inherits from the sendmail connector; the sendmail connector has a method _validate_email_string which calls validate_email which appears to be this package. Our requirements.txt pins 1.3 which is the most recent version; unfortunately that most recent version was published 9 years ago. I'm not sure why the tests started failing just now (my guess is it's something to do with bumping the version of pytest) but regardless we probably don't want to be using a library that hasn't been updated in 9 years.

There is an actively maintained fork but it says "Pypi removed newer versions due to license issues". So...maybe the thing to do is to migrate to a different email validation package entirely? Josh Tauberer has an email validation package we could switch to.

@bmos
Copy link
Contributor Author

bmos commented Sep 18, 2024

I did try reverting to the old version of pytest et al and it was still failing, but I agree it's probably a good idea to use better validation. (especially since the old solution allowed ",com" which is not valid afaik).
I should be able to do that someday soon.

@shaunagm
Copy link
Collaborator

I mentioned you in the other thread but I'll also add here that this failure does not seem to be specific to this PR. It's happening in all other recent PRs but not the most recent merged commit (which was 11:56am EDT yesterday Sep 17th). Given that there have been no updates to the github images between then and now, and the errors are happening at least on mac and ubuntu, it seems unlikely to be caused by a change to the runners. Maybe a change to uv? I don't think we pin our version of uv on install and there have been one, possibly two releases of uv since noon yesterday.

@bmos
Copy link
Contributor Author

bmos commented Sep 19, 2024

@bmos bmos force-pushed the mod-action branch 3 times, most recently from 0d3940b to 49c23ca Compare September 19, 2024 18:46
@shaunagm
Copy link
Collaborator

shaunagm commented Oct 1, 2024

This is so weird. It's like whatever was causing the issue was fixed in Ubuntu for 3.9 but not in Mac/Windows until 3.12.

@shaunagm
Copy link
Collaborator

shaunagm commented Oct 1, 2024

For clarity, when you say "this now works great on 3.12" - do you mean that a validation error is raised as expected when given ",com"?

I'm trying to wrap my head around where the problem could be coming from. Because until recently these same tests passed (on ubuntu and mac, at least) meaning that a validation error was raised, no? So something changed (either by parsons, uv, github, python, etc) that caused the validation error not to be raised. But now with this new package it's sometimes being raised.

@bmos
Copy link
Contributor Author

bmos commented Oct 2, 2024

I think that one of our dependencies must have updated or something like that. Like if one of our dependencies has a subdependency that is not version pinned, it could potentially do something like this.

What I did to get the tests passing on 3.12 was change out the email validation library, but it still is passing ,con on certain configurations.

@bmos
Copy link
Contributor Author

bmos commented Oct 2, 2024

We just recently updated some dependencies, so it could be related to that. But if I remember correctly, that pull request had all of the checks passed.

Unless maybe the checks didn't run because a particular file was being updated...

Probably time to jump into some actions logs and see what changed.

@austinweisgrau
Copy link
Collaborator

austinweisgrau commented Oct 9, 2024

I fixed the email parsing issue with #1146, if someone wants to give it the ol' review :)

@shaunagm
Copy link
Collaborator

@austinweisgrau @bmos alas now all the tests are failing. FYI I did resolve the merge conflict between @austinweisgrau's PR and this one, perhaps incorrectly. But it also may be that the PR doesn't fully address the issue (I'm still unclear how a problem in Python 3.12 could cause our tests for 3.8-3.11 to fail, esp in the weird pattern they did (mostly but not entirely on Windows & Mac rather than Ubuntu)

@austinweisgrau
Copy link
Collaborator

IMO this PR should be split up a bit. In particular the isort formatting should be its own PR. Because hundreds of files are changed with the isort formatting, it makes it very difficult to detect any other unwanted changes that are happening here, and also difficult to evaluate, for example, what changes in particular may be resulting in test failures.

@shaunagm
Copy link
Collaborator

Yeah that's fair. We'd talked about moving the isort stuff to a separate PR a few weeks ago for precisely that reason but got derailed by the email address bug. @bmos if you'd be up for it can you split the PRs?

@bmos
Copy link
Contributor Author

bmos commented Oct 10, 2024

I would be happy to, that should be pretty easy.

@bmos
Copy link
Contributor Author

bmos commented Oct 10, 2024

I'm also pretty sure that none of these changes are creating test failures, but again, totally happy to break that out.

@shaunagm
Copy link
Collaborator

Thanks so much @bmos, regardless of the causes it'll be easier to read & reason about this way.

@bmos bmos force-pushed the mod-action branch 2 times, most recently from f96a9c5 to e0d84e5 Compare October 10, 2024 18:26
@bmos
Copy link
Contributor Author

bmos commented Oct 10, 2024

Okay, that should take care of that.

@shaunagm
Copy link
Collaborator

Looks good - thank you!

@shaunagm shaunagm merged commit 1d1f988 into move-coop:main Oct 10, 2024
69 checks passed
@austinweisgrau
Copy link
Collaborator

hell yea good work

@bmos bmos deleted the mod-action branch October 11, 2024 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants